﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FlatRedBall;
using FlatRedBall.Graphics;
using FlatRedBall.Math.Geometry;
using FlatRedBall.Input;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

using FlatRedBall.Graphics.Animation;
using HarpoonMan.Utilities;

namespace HarpoonMan.WorldObjects
{
    class Platform : Obstacle
    {
        #region Fields

        private string _contentManagerName;
        private Sprite _sprite;

        #endregion

        #region Methods

        // Constructor
        public Platform(string contentManagerName)
        {
            // Set the ContentManagerName and call Initialize:
            _contentManagerName = contentManagerName;

            // If you don't want to add to managers, make an overriding constructor
            Initialize(true);
        }


        protected virtual void Initialize(bool addToManagers)
        {
            // Here you can preload any content you will be using
            // like .scnx files or texture files.
            if (addToManagers)
            {
                AddToManagers(null);
            }
        }

        public virtual void AddToManagers(Layer layerToAddTo)
        {
            SpriteManager.AddPositionedObject(this);

            _sprite = SpriteManager.AddSprite(@"Content\Scenery\Platform\Platform1");
            _sprite.AttachTo(this, false);
            _sprite.PixelScale();

            Collision = ShapeManager.AddAxisAlignedRectangle();
            Collision.AttachTo(this, false);
            Collision.ScaleX = _sprite.ScaleX;
            Collision.ScaleY = _sprite.ScaleY * .50f;
            Collision.RelativeY = 1.0f;

            Collision.Visible = false;
        }

        public virtual void Activity()
        {

        }

        public virtual void Destroy()
        {
            base.Destroy();
            SpriteManager.RemoveSprite(_sprite);
            SpriteManager.RemovePositionedObject(this);
        }

        #endregion

    }
}

